package com.example.controller;

import com.example.entity.Product;
import com.example.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class ProductController {
    @Autowired
    private ProductService productService;
    @GetMapping("/add")
    public String add(Product product){
        productService.addProduct(product);
        return "ok";
    }

    @GetMapping("/add1")
    public String add1(Product product){
        productService.addProduct1(product);
        return "ok";
    }

    @GetMapping("/update")
    public String update(Product product){
        productService.updatePro(product);
        return "ok";
    }

    @GetMapping("/update1")
    public String update1(){
        productService.updatePro1();
        return "ok";
    }

    @GetMapping("/update2")
    public String update2(Product product){
        productService.updatePro2(product);
        return "ok";
    }

    @GetMapping("/getData")
    public Object getData(){
        List<Product> list = productService.getPorduct();
        return "ok";
    }

    @GetMapping("/getData1")
    public Object getData1(){
        List<Product> list = productService.getData2();
        return "ok";
    }

    @GetMapping("/getData2")
    public Object getData2(){
        Product product = productService.getData3();
        return "ok";
    }




}
